home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / NeXTWORLD_DragLab / Text_Console.m < prev   
Text File  |  1995-06-12  |  629b  |  28 lines

  1. #import "Text_Console.h"
  2. #import <stdarg.h>
  3.  
  4. @implementation Text(Text_Console)
  5. #define BUFFERSIZE 512
  6.  
  7. - (int) printf:(const char *) format, ...
  8. {
  9.   int result, length = [self textLength];
  10.   char buffer[BUFFERSIZE];
  11.   va_list    ap;
  12.   
  13.   va_start(ap, format);
  14.   result = vsprintf(buffer, format, ap);
  15.   va_end(ap);
  16.  
  17.   // this is how one puts text into a Text object and goes to that selection.
  18.  
  19.   // put the cursor in the very last location and push the buffer in
  20.   [[self setSel:length :length] replaceSel:buffer];
  21.  
  22.   // scroll so that it is visible and redisplay
  23.   [[self scrollSelToVisible] display];
  24.   
  25.   return result;
  26. }
  27. @end
  28.